﻿using Gonte.Algorithms;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace MyUtilitiesTest
{
    /// <summary>
    ///This is a test class for ShellSorter
    ///</summary>
    [TestClass()]
    public class ShellSorterTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestMethod()]
        public void ShellSorterSortNullListTest()
        {
            ShellSorter<String>.Sort(null); // Does nothing
        }

        [TestMethod()]
        public void ShellSorterSortEmptyListTest()
        {
            List<String> stringList = new List<String>();
            ShellSorter<String>.Sort(stringList); // Does nothing
        }

        [TestMethod()]
        public void ShellSorterSortListOfStringTest()
        {
            List<String> stringList = new List<String>();
            stringList.Add("F");
            stringList.Add("E");
            stringList.Add("C");
            stringList.Add("D");
            stringList.Add("B");
            stringList.Add("A");

            ShellSorter<String>.Sort(stringList);

            Assert.AreEqual("A", stringList[0]);
            Assert.AreEqual("B", stringList[1]);
            Assert.AreEqual("C", stringList[2]);
            Assert.AreEqual("D", stringList[3]);
            Assert.AreEqual("E", stringList[4]);
            Assert.AreEqual("F", stringList[5]);
        }

        [TestMethod()]
        public void ShellSorterSortArrayOfStringTest()
        {
            String[] stringArray = new String[6];
            stringArray[0] = "F";
            stringArray[1] = "E";
            stringArray[2] = "C";
            stringArray[3] = "D";
            stringArray[4] = "B";
            stringArray[5] = "A";

            ShellSorter<String>.Sort(stringArray);

            Assert.AreEqual("A", stringArray[0]);
            Assert.AreEqual("B", stringArray[1]);
            Assert.AreEqual("C", stringArray[2]);
            Assert.AreEqual("D", stringArray[3]);
            Assert.AreEqual("E", stringArray[4]);
            Assert.AreEqual("F", stringArray[5]);
        }
    }
}
